
#ifndef SOFTTIMER_H
#define	SOFTTIMER_H

#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>

#ifdef	__cplusplus
extern "C" {
#endif /* __cplusplus */

#define SOFTWAER_TIMER_VER  (0x02)

#define SW_TMR_MS(cnt)   (((uint32_t)cnt) * ((uint32_t)10))
#define SW_TMR_100US(cnt) (cnt * 1U)

typedef struct { 
    uint32_t start; 
    uint32_t count; 
} SOFTTIMER_TIMEOUT;

void SOFTTIMER_Start(void);
void SOFTTIMER_Stop(void);
void SOFTTIMER_StartTimeOut(SOFTTIMER_TIMEOUT* timeout, uint32_t delay_ticks);
void SOFTTIMER_ResetTimeOut(SOFTTIMER_TIMEOUT* timeout);
bool SOFTTIMER_IsTimeoutReached(const SOFTTIMER_TIMEOUT * const timeout);

void SOFTTIMER_TickHandler(void);

#ifdef	__cplusplus
}
#endif /* __cplusplus */

#endif	/* SOFTTIMER_H */

